﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KLY.DataModels;
using KLY.Tools;

namespace KLY.ServiceCore
{
    public class GetInviterName : ServiceBase<GetInviterRequest, GetInviterResponse>
    {
        public GetInviterName(GetInviterRequest request)
        {
            this._request = request;
        }

        public override GetInviterResponse Process()
        {
            if(!Validate())
            {
                return new GetInviterResponse
                {
                    Ok = false
                };
            }
            base.Url = string.Format("http://{0}/v1/api/101018/?member_id={1}", BizCommon.Domain, this._request.Member_id);
            base.Method = HttpMethod.GET;
            base.ListHead = new List<RequestHead>
                {
                    new RequestHead
                    {
                        HeaderName="version",
                        HeaderValue="1.0.0"
                    }
                };
            return base.Process();
        }

        private bool Validate()
        {
            if(string.IsNullOrWhiteSpace(this._request.Member_id))
            {
                return false;
            }
            return true;
        }
        private GetInviterRequest _request;
    }
}
